﻿

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/jsTree/style.min.css" rel="stylesheet">
    <link href="~/Content/Css/plugins/iCheck/custom.css" rel="stylesheet">
    <style>
        .inp {
            width: 177px;
            padding: 2px 4px;
            display: inline;
        }

        .lab {
            margin-bottom: 5px;
            font-weight: 700;
            cursor: default;
            width: 80px;
            text-align: center;
        }

        .mybtn-group {
            margin-top: -4px;
        }

        .displayNone {
            display: none;
        }
    </style>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>中介信息</h5>
            </div>
            <div class="ibox-content" style="padding-bottom: 20px;display">
                <div class="row row-lg">

                    <div class="col-sm-12">
                        <form id="mainForm">

                            <div id="toolbar">

                                <label class="lab">楼盘名称</label>
                                <input type="text" class="form-control inp" id="Name" name="Name">
                                <label class="lab">楼盘地址</label>
                                <input type="text" class="form-control inp" id="Address" name="Address">

                                <div class="btn-group mybtn-group" style="padding-top:5px;">
                                    <button class="btn btn-white btn-xs" type="submit">查询</button>&nbsp;
                                    <button class="btn btn-primary btn-xs" type="reset">清空</button>
                                </div>

                            </div>
                        </form>

                    </div>
                    <div class="col-sm-12">
                        <div class="btn-group">
                            <button id="selBtn" type="button" class="btn btn-info" title="选择中介">
                                选择楼盘
                            </button>
                        </div>
                    </div>
                </div>

                <div class="row">
                    @*<div class="col-sm-12 displayNone" style="padding:15px 15px 15px 15px">

                        </div>*@
                    <div class="col-sm-12">
                        <table id="table"></table>
                    </div>

                </div>
            </div>

        </div>
    </div>



    <script src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>
    <script src="~/Scripts/plugins/layer/layer.min.js"></script>

    <script src="~/Scripts/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="~/Scripts/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script src="~/Scripts/plugins/layer/laydate/laydate.js"></script>
    <script src="~/Scripts/plugins/iCheck/icheck.min.js"></script>
    <script>

        parent.buildName = '';
        parent.buildID = 0;

        var $table = $("#table");

        $("#mainForm").submit(function () {
            $table.bootstrapTable('refresh');
            return false;
        });

        $(function () {

            //1.初始化Table

            var table_columns = [
                {
                    width: 38,
                    field: 'selected',
                    checkbox: true,
                }, {
                    field: 'no',
                    title: '行号',
                    align: 'center',
                    formatter: function (value, row, index) { return index + 1; }
                }, {
                    field: 'name',
                    title: '楼盘名称',
                    align: 'center'
                }, {
                    field: 'address',
                    title: '楼盘地址',
                    align: 'center'
                }, {
                    field: 'remark',
                    title: '楼盘说明',
                    align: 'center'
                }, {
                    field: 'buildingTypeID',
                    title: '类型',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var txt = "";
                        switch (value) {
                            case 1:
                                txt = "住宅";
                                break;
                            case 2:
                                txt = "旅游地产";
                                break;
                            case 3:
                                txt = "门市";
                                break;
                            case 4:
                                txt = "商铺";
                                break;
                            default:
                                txt = "无";
                                break;
                        }
                        return txt;
                    }
                }, {
                    field: 'buildingInfo',
                    title: '楼盘信息',
                    align: 'center'
                }
            ];

            var orderBy = "";
            var table_queryParams = function (params) {
                var data = {};
                if (parent.CustomerSource_Index_data != undefined) {
                    data = parent.CustomerSource_Index_data;
                } else {
                    data = $("#mainForm").formToJson(false);
                }
                parent.CustomerSource_Index_data = undefined;
                data.pageIndex = (params.offset / params.limit) + 1;
                data.pageSize = params.limit;
                //data.orderBy = this.sortName;
                //data.orderByType = this.sortOrder;

                return data;
            };

            $table.initTable("/NewHouse/BuildingStatistics/BuildingsIndexAsync", table_columns, 180, table_queryParams);

            //选择楼盘
            $("#selBtn").click(function () {

                var selected = $table.bootstrapTable('getSelections');

                if (selected.length > 1) {
                    layer.msg("只能选择一条数据！", { icon: 5, time: 2000 });
                    return;
                }

                if (selected.length == 0) {
                    layer.msg("请选择数据！", { icon: 5, time: 2000 });
                    return;
                }
                selData(selected[0].id, selected[0].name);

            });

            function selData(id, name) {

                //传值
                @*var body = parent.layer.getChildFrame('body', '@ViewData["layerindex"]');
                body.find('#buildName').val(name);
                body.find('#buildID').val(id);*@
                parent.buildName = name;
                parent.buildID = id;

                //关闭
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);

            }


            $("#RefreshBtn").click(function () {
                $table.bootstrapTable('refresh');
            });
        });


    </script>
</body>
</html>
